<template>
  <div class="venus-list-page">
    <!--签约查询界面-->
    <div class="page-search">
      <el-row type="flex" class="list-items">
        <div class="venus-input-box">
          <label>债券代码</label>
          <el-input
            v-model="table.bond_table.bond_code"
            class="venus-input-middle"
            placeholder="请输入债券名称"
          />
        </div>
        <div class="venus-input-box">
          <label>债券名称</label>
          <el-input
            v-model="table.bond_table.bond_name"
            class="venus-input-middle"
            placeholder="请输入债券名称"
          />
        </div>

        <div class="venus-input-box">
          <label>市场</label>
          <el-select
            v-model="table.bond_table.market_code"
            class="venus-input-middle"
            placeholder="--请选择--"
          >
            <el-option
              v-for="(value,key,index) in dict.marketCode"
              	:key="index"
              	:label="value"
              	:value="key"
            />
          </el-select>
        </div>
      </el-row>

      <el-row>
        <div class="venus-btn-box" style="text-align: center;">
          <el-button type="success" @click="search">查询</el-button>
          <el-button type="info" plain @click="resetForm">重置</el-button>
          <el-button type="success" @click="search">导入</el-button>
          <el-button type="success" @click="addBean">新增</el-button>
        </div>
      </el-row>
    </div>
    <!--    查询列表返显-->
    <div class="page-list">
      <el-row type="flex" justify="space-between" class="page-list-head">
        <div class="title">查询结果</div>
      </el-row>
      <table-pagination
        :table-data="table.bond_table.tableData"
        :table-header-config="table.tableHeaderConfig"
        highlight-current-row
        :total="table.bond_table.total"
        :page-size="table.bond_table.limit"
        :now-page="table.bond_table.nowPage"
        :operation-config="table.operationConfig"
        @current-change="handleCurrentChange"
      />
    </div>
  </div>
</template>

<script>
  /* 自定义数据加载 */
  import request from '@/utils/request'
  import * as kk from '@/utils/k-utils'

  export default {
    name: 'BondInfo',
    data() {
      return {
        /* 数据字典*/
        dict: {
             marketCode: []
          },
          /* 表格*/
          table: {
            operationConfig: { // 表格操作配置
              fixed: 'left',
              width: 200,
              operationButton: [
                // 每一个操作。value:操作文字；func:回调函数
                { value: '修改', func: this.myModify },
                { value: '删除', func: this.myDelete }
              ]
            },
            tableHeaderConfig: [ // 表头配置
              { prop: 'market_code', label: '市场' },
              { prop: 'bond_code', label: '债券代码' },
              { prop: 'bond_name', label: '债券名称' },
              { prop: 'base_rate', label: '基础利率(%)' },
              { prop: 'coupon_rate', label: '票面利率(%)' },
              { prop: 'begin_date', label: '起息日' },
              { prop: 'end_date', label: '到期日' }

            ],
            bond_table: {
              limit: 5,
              total: 0,
              nowPage: 0,
              tableData: [], // 表格数据
              exeid: 'M8201EQ0012',
              //查询参数
              bond_code: '',
              bond_name: '',
              market_code: ''
            }
          }
      }
    },
    mounted() {
      // 初始化调用
      this.init()
    },
    methods: {
      init: function() {
        kk.k_load_dict(this,'marketCode','t8_market_code')
      },
      search() { // 查询函数
      this.table.bond_table.nowPage = 1
      kk.k_load_table(this, 'bond_table', '/bond')
      },
      myModify(item, index) {
        console.log(item, index, '-----编辑对象')
      },
      myDelete(item, index) {
        console.log(item, index, '-----删除对象')
      },
      addBean() {
        this.$router.push({
          path: '/add_bond_info'
        })
      },
      resetForm() {
        this.table.bond_table.bond_code = ''
        this.table.bond_table.bond_code = ''
        this.table.bond_table.market_code = ''
      },
      handleCurrentChange(val){
        this.table.bond_table.nowPage = val;
         kk.k_load_table(this, 'bond_table', '/bond')
      }
    }
  }
</script>

<style scoped>
    /*让文本可以被选中*/
    .venus-list-page {
      -moz-user-select: text; /*火狐*/
      -webkit-user-select: text; /*webkit浏览器*/
      -ms-user-select: text; /*IE10*/
      -khtml-user-select: text; /*早期浏览器*/
      user-select: text;
    }
</style>
